package edu.ssdut.revise.models;

import com.github.javaparser.ast.body.VariableDeclarator;

import java.util.List;

/**
 * customized field node for visualization.<br/>
 * Note that in JavaParser, code like {@code int a, b;} will be parsed as a single field,
 * whereas here we split all variables in one certain field into several fields.
 */
public class VisFieldNode extends VisBaseNode {
    private final List<String> annotations;
    private final String type;
    private final String identifier;
    private final List<String> modifiers;

    public VisFieldNode(VariableDeclarator v, List<String> annotations, List<String> modifiers) {
        super(v);
        this.identifier = v.getNameAsString();
        this.annotations = annotations;
        this.type = v.getType().asString();
        this.modifiers = modifiers;
    }

    @Override
    public String toString() {
        return "Field:" + System.lineSeparator() +
                (annotations.size() > 0 ? annotations + " " : "") +
                modifiers.toString() + " " +
                type + " " +
                identifier + System.lineSeparator();
    }

    @Override
    public String getTypeName() {
        return "FieldNode";
    }

    public List<String> getAnnotations() {
        return annotations;
    }

    public String getType() {
        return type;
    }

    public String getIdentifier() {
        return identifier;
    }

    public List<String> getModifiers() {
        return modifiers;
    }
}
